<?php
namespace frontend\modules\address\lib;
use frontend\modules\address\models\EcsRegion;

/**
 * Class AddExchange
 * @package backend\modules\orders\lib\AddExchange
 */

class AddExchange{

    public function __construct()
    {

    }

    /**
     * @param $arrInfo
     * @return mixed
     */
    public function exchangeArr($arrInfo)
    {
        $_countryId = $arrInfo['country'];
        $_provinceId = $arrInfo['province'];
        $_cityId = $arrInfo['city'];
        $_districtId = $arrInfo['district'];
        $arrInfo['country_name'] = EcsRegion::findOne($_countryId)->region_name;
        $arrInfo['province_name'] = EcsRegion::findOne($_provinceId)->region_name;
        $arrInfo['city_name'] = EcsRegion::findOne($_cityId)->region_name;
        $arrInfo['district_name'] = EcsRegion::findOne($_districtId)->region_name;
        return $arrInfo;
    }

    /**
     * @param $model
     * @return mixed
     */
    public function exchangeObj($model)
    {
        $_countryId = $model->country;
        $_provinceId = $model->province;
        $_cityId = $model->city;
        $_districtId = $model->district;
        $model->country_name= EcsRegion::findOne($_countryId)->region_name;
        $model->province_name = EcsRegion::findOne($_provinceId)->region_name;
        $model->city_name=EcsRegion::findOne($_cityId)->region_name;
        $model->district_name=EcsRegion::findOne($_districtId)->region_name;
    }
}
?>